﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Map
{
    private int[,] map;

    public int[,] MAP
    {
        get
        {
            return map;
        }
    }

    public Map()
    {
        map = new int[8, 15];
        int i = 0, j = 0;
        for (i = 0; i < 8; i++)
        {
            for (j = 0; j < 15; j ++)
            {
                map[i, j] = 0;
            }
        }
    }
}

public class MapEditor : MonoBehaviour
{
    private Map map;
    private Ray hit;
    private RaycastHit hitInfo;

    private void Start()
    {
        map = new Map();
    }

    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            hit = Camera.main.ScreenPointToRay(Input.mousePosition);
            if (Physics.Raycast(hit, out hitInfo))
            {
                if (hitInfo.collider.tag == "BlockButton")
                {
                    hitInfo.collider.GetComponent<Renderer>().material.color = Color.black;
                    map.MAP[(int)hitInfo.collider.transform.position.x, (int)hitInfo.collider.transform.position.z] = 1;
                }
            }
        }
    }
}
